package org.xxd.kafka.clients.common.network;

import java.io.IOException;
import java.nio.channels.ScatteringByteChannel;

/**
 * @author: XiaoDong.Xie
 * @create: 2020-09-28 10:09
 * @description:
 */
public interface Receive {
    /**
     * The numeric id of the source from which we are receiving data.
     */
    String source();

    /**
     * Are we done receiving data?
     */
    boolean complete();

    /**
     * Read bytes into this receive from the given channel
     *
     * @param channel The channel to read from
     * @return The number of bytes read
     * @throws IOException If the reading fails
     */
    long readFrom(ScatteringByteChannel channel) throws IOException;
}
